package com.spring.log4j2.intercept;

import org.apache.log4j.Logger;
import org.apache.log4j.MDC;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

/**
 * Created by devsun on 2017/11/1.
 */
@Aspect
@Component
public class AopClass {

    private Logger logger = Logger.getLogger(AopClass.class);
//    @Pointcut(value = "* com.spring.log4j2.controller.*.*(..)")

    //* com.xyz.service.*.*（..）
    @Before("execution(* com.spring.log4j2.controller.*.*(..))")
    public void doBefore(){
        logger.info("AOP");
        MDC.put("userID",234397897);
    }
}
